import Vue from 'vue'
import * as echarts from 'echarts'
import './map/js/china'
import './map/js/world'
const install = function () {
    Object.defineProperties(Vue.prototype, {
        $myEcharts: {
            get() {
                return {
                    // 中国疫情图
                    chinaMap(id, data) {
                        // var myChart = echarts.init(id);
                        var myChart = echarts.init(document.getElementById(id));
                        var option = {
                            tooltip: {
                                enterable: true,
                                formatter: '{b}<br/>新增确诊{c}<hr/>详情',
                                // formatter:function(data) {
                                //     return data.name+':'+data.value
                                // },
                                textStyle: {
                                    fontSize: 4,
                                    lineHeight: 20
                                }
                            },
                            visualMap: [{
                                // orient: 'horizontal',
                                type: 'piecewise',
                                bottom: 0,
                                // textGap: 0,
                                itemGap: 0,
                                itemWidth: 6,
                                // itemHeight: 10,
                                // padding: 2,
                                textStyle: {
                                    fontSize: 9,

                                },
                                pieces: [
                                    {
                                        min: 0,
                                        max: 0,
                                        color: '#FFFFFF',

                                    },
                                    {
                                        min: 1000,
                                        max: 1500,
                                        color: '#FDFDCF',

                                    },
                                    {
                                        min: 1600,
                                        max: 2000,
                                        color: '#EF9E83',

                                    },
                                    {
                                        min: 2500,
                                        max: 3500,
                                        color: '#E55A4E',

                                    },
                                    {
                                        min: 4000,
                                        max: 5500,
                                        color: '#4F070D',

                                    },
                                    {
                                        min: 6000,
                                        max: 8000,
                                        color: '#1989fa',

                                    },
                                    {
                                        min: 8500,
                                        max: 10000,
                                        color: '#0e134d',

                                    }
                                ],
                            }],
                            series: [
                                {
                                    name: "省",
                                    type: "map",
                                    map: 'china',
                                    roam: false,
                                    zoom: 1.2,
                                    aspeactScale: 0.75,
                                    top: 40,
                                    layoutCenter: ['5%', '5%'],
                                    label: {
                                        normal: {
                                            show: true,
                                            textStyle: {
                                                fontSize: 8
                                            }
                                        }
                                    },
                                    itemStyle: {
                                        normal: {
                                            areaColor: 'rgba(0,255,236,0)',
                                            borderColor: 'rgba(0,0,0,0.2)'
                                        },
                                        emphasis: {
                                            areaColor: 'rgba(255,180,0,0.8)',
                                            shadowOffsetX: 0,
                                            shadowOffsetY: 0,
                                            shadowBlur: 20,
                                            borderWidth: 0

                                        },
                                    },
                                    data
                                    // data:[{name:'北京',value:10000},{name:'上海',value:20000}]
                                }
                            ],
                        };
                        // 使用刚指定的配置项和数据显示图表。
                        myChart.setOption(option);

                    },
                    // 世界疫情图
                    worldMap(id, data) {
                        var myChart = echarts.init(document.getElementById(id));
                        // var myChart = echarts.init(id);
                        var option = {
                            tooltip: {
                                triggerOn: 'click',
                                enterable: true,
                                formatter(item) {
                                    return item.name + ':确诊人数' + item.value
                                },

                            },
                            visualMap: [{
                                orient: 'vertical',
                                type: 'piecewise',
                                bottom: 0,
                                textStyle: {
                                    fontSize: 9,

                                },
                                pieces: [
                                    {
                                        min: 0,
                                        max: 0,
                                        color: '#FFFFFF',

                                    },
                                    {
                                        min: 1,
                                        max: 10000,
                                        color: '#FDFDCF',

                                    },
                                    {
                                        min: 10000,
                                        max: 100000,
                                        color: '#EF9E83',

                                    },
                                    {
                                        min: 100000,
                                        max: 500000,
                                        color: '#E55A4E',

                                    },
                                    {
                                        min: 500000,
                                        max: 1000000,
                                        color: '#4F070D',

                                    },
                                    {
                                        min: 1000000,
                                        max: 1500000,
                                        color: '#EF9E83',

                                    },
                                    {
                                        min: 1500000,
                                        max: 2000000,
                                        color: '#FDFDCF',

                                    }
                                ],
                            }],

                            series: [
                                {
                                    name: "国",
                                    type: "map",
                                    map: 'world',
                                    // nameMap: country,
                                    roam: false,
                                    zoom: 1.2,
                                    aspeactScale: 0.75,
                                    top: 40,
                                    layoutCenter: ['5%', '5%'],
                                    label: {
                                        normal: {
                                            show: false,
                                            textStyle: {
                                                fontSize: 8
                                            }
                                        }
                                    },
                                    itemStyle: {
                                        normal: {
                                            areaColor: 'rgba(0,255,236,0)',
                                            borderColor: 'rgba(0,0,0,0.2)'
                                        },
                                        emphasis: {
                                            areaColor: 'rgba(255,180,0,0.8)',
                                            shadowOffsetX: 0,
                                            shadowOffsetY: 0,
                                            shadowBlur: 20,
                                            borderWidth: 0

                                        },
                                    },
                                    data
                                }
                            ]
                        }
                        myChart.setOption(option);

                    },
                    // 城市疫情图
                    cityMap() {
                        var myChart = echarts.init(id);
                        var option = {
                            tooltip: {
                                triggerOn: 'click',
                                enterable: true,
                                formatter(data) {
                                    return data.name
                                }
                            },
                            visualMap: [{
                                orient: 'vertical',
                                type: 'piecewise',
                                bottom: 0,
                                pieces: [
                                    {
                                        min: 0,
                                        max: 0,
                                        color: '#FFFFFF',

                                    },
                                    {
                                        min: 1,
                                        max: 10000,
                                        color: '#FDFDCF',

                                    },
                                    {
                                        min: 10000,
                                        max: 100000,
                                        color: '#EF9E83',

                                    },
                                    {
                                        min: 100000,
                                        max: 500000,
                                        color: '#E55A4E',

                                    },
                                    {
                                        min: 500000,
                                        // max:10000,
                                        color: '#4F070D',

                                    }
                                ],
                            }],

                            series: [
                                {
                                    name: "国",
                                    type: "map",
                                    map: 'world',
                                    nameMap: country,
                                    roam: false,
                                    zoom: 1.2,
                                    aspeactScale: 0.75,
                                    top: 40,
                                    layoutCenter: ['5%', '5%'],
                                    label: {
                                        normal: {
                                            show: false,
                                            textStyle: {
                                                fontSize: 8
                                            }
                                        }
                                    },
                                    itemStyle: {
                                        normal: {
                                            areaColor: 'rgba(0,255,236,0)',
                                            borderColor: 'rgba(0,0,0,0.2)'
                                        },
                                        emphasis: {
                                            areaColor: 'rgba(255,180,0,0.8)',
                                            shadowOffsetX: 0,
                                            shadowOffsetY: 0,
                                            shadowBlur: 20,
                                            borderWidth: 0

                                        },
                                    },
                                    data
                                }]
                        }

                        myChart.setOption(option);
                    }
                }
            }
        }
    })
}
export default install